#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

int n, q;

/*
if a is not in the form of  (111111111....1111)2

we can construct b = ~a     
so b xor a = (11111111...111)2   b & a = 0  gcd(a ^ b, a & b) = (1111111..111)2

if a is in the form of  (111111111....1111)2

According to this formula gcd(a - b, b) = gcd(a, b)  (a > b);
so we just need find the biggest factor of a
*/

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


    
    cin >> q;
    while(q--){
        cin >> n;

        int k = 1;
        while(k <= n){
            k <<= 1;
        }
        k --;

        if(k != n){
            cout << k << '\n';
        }else{
            bool flag = false;
            for(int i = 2; i * i <= n; i ++){
                if(n % i == 0) {
                    flag = true;
                    cout << n / i << '\n';
                    break;
                }
            }

            if(!flag) cout << 1 << '\n';

        }
    }

    return 0;
}